package com.zd.web.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zd.entity.Novel;
import com.zd.entity.PageBean;
import com.zd.entity.User;
import com.zd.service.NovelService;
import com.zd.service.impl.NovelServiceImpl;


/**
 * Servlet implementation class SousuoNovelServlet
 */
@WebServlet("/SousuoNovelServlet")
public class SousuoNovelServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	NovelService ns = new NovelServiceImpl();
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
//		response.getWriter().append("Served at: ").append(request.getContextPath());
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		String sousuo=request.getParameter("query");
		System.out.println("进入");
		//分页一波
		int aPageNum=15;
		String num=request.getParameter("nowPage");
		int nowPage=Integer.parseInt(num==null?"1":num);
		PageBean<Novel> pageBean=ns.sousuoSelectUser(aPageNum,nowPage,sousuo);
		System.out.println(pageBean);
		request.setAttribute("pageBean", pageBean);
		request.getRequestDispatcher("NovelSeach.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
//		doGet(request, response);
	}

}
